#ifndef EDGEMAP_HPP
#define EDGEMAP_HPP
#include <map>
#include "Mesh.hpp"
// An edge to a unique edge id
class EdgeMap
{
public:
   int operator[](const Edge& aEdge)
   {
      MapType::iterator i = mEdgeIds.find(aEdge);
      if (i != mEdgeIds.end())
      {
         return i->second;
      }
      else
      {
         int id = mEdgeIds.size();
         mEdgeIds[aEdge] = id;
         return id;
      }
   }

   void AddFace(Face& aFace, int& e1, int& e2, int& e3)
   {
      EdgeMap& m(*this);
      e1 = m[OrderEdge(aFace.vertex[0], aFace.vertex[1])];
      e2 = m[OrderEdge(aFace.vertex[1], aFace.vertex[2])];
      e3 = m[OrderEdge(aFace.vertex[2], aFace.vertex[0])];
   }
   typedef std::map<Edge, int> MapType;

   const MapType& GetMap() const { return mEdgeIds; }

private:
   
   MapType mEdgeIds;

};
#endif
